<template>
  <div>
    <el-container class="main-el-contarner">
      <el-main>
        <div class="kanbao-bigbox">
          <div class="righttop-search-box">
            <el-form
              :inline="true"
              :model="param"
              label-width="100px"
              @submit.native.prevent
            >
              <el-form-item label="告警等级：" label-width="90px">
                <el-select
                  v-model="param.warnStatus"
                  placeholder="告警等级"
                  :clearable="true"
                  size="small"
                  style="width: 150px"
                >
                  <el-option
                    v-for="item in AlarmLevelData"
                    :key="item.data_value"
                    :label="item.data_text"
                    :value="item.data_value"
                  ></el-option>

                  <!--                  <el-option label="一般" value="1"></el-option>-->
                  <!--                  <el-option label="较重" value="2"></el-option>-->
                  <!--                  <el-option label="严重" value="3"></el-option>-->
                </el-select>
              </el-form-item>
              <el-form-item label="" label-width="10px">
                <el-input
                  placeholder="请输入事件名称或关键字检索"
                  clearable
                  v-model="param.name"
                  size="small"
                  style="width: 350px"
                  @keyup.enter.native="onSearch"
                >
                  <i slot="prefix" class="el-input__icon el-icon-search"></i>
                </el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" size="small" @click="onSearch">查找</el-button>
              </el-form-item>
              <el-form-item style="float: right">
                <el-button
                  type="text"
                  v-if="selectionChangeData == ''"
                  disabled
                  style="color: #cdc5bf"
                  ><i class="el-icon-delete"></i>删除数据</el-button
                >
                <el-button type="text" v-else style="color: #ff0000" @click="delClick"
                  ><i class="el-icon-delete"></i> 删除数据</el-button
                >
              </el-form-item>
              <el-form-item style="float: right">
                <el-button type="text" style="color: #18bc9c" @click="handleAdd"
                  ><i class="el-icon-plus"></i> 新增设置</el-button
                >
              </el-form-item>
            </el-form>
          </div>
          <div class="container-box">
            <el-table
              :data="tabledatas"
              border
              stripe
              max-height="480px"
              @row-dblclick="rowdbclick"
              @row-click="handleRowClick"
              :header-cell-style="{
                background: '#cfcfcf',
                color: '#000000',
                'text-align': 'center',
              }"
              ref="talbes"
              :cell-style="{ 'text-align': 'center' }"
              style="width: 100%"
              size="small"
              @selection-change="selectionChange"
            >
              <el-table-column
                type="selection"
                header-align="center"
                width="60"
              ></el-table-column>
              <el-table-column prop="event_name" label="告警名称" width="150">
              </el-table-column>
              <el-table-column prop="is_turn_to_order" label="是否转工单" width="150">
                <template slot-scope="scope">
                  <font v-if="scope.row.is_turn_to_order == '1'">是</font>
                  <font v-else-if="scope.row.is_turn_to_order == '0'">否</font>
                  <font v-else>/</font>
                </template>
              </el-table-column>
              <el-table-column prop="alarm_level" label="告警等级" width="120">
                <template slot-scope="scope">
                  <font v-if="scope.row.alarm_level == '0'">轻微告警</font>
                  <font v-else-if="scope.row.alarm_level == '1'">一般告警</font>
                  <font v-else-if="scope.row.alarm_level == '2'">严重告警</font>
                  <!--                  <font v-else-if="scope.row.alarm_level == '4'">警告</font>-->
                  <!--                  <font v-else-if="scope.row.alarm_level == '5'">通知</font>-->
                  <!--                  <font v-else-if="scope.row.alarm_level == '255'">所有级别</font>-->
                  <font v-else>/</font>
                </template>
              </el-table-column>
              <el-table-column prop="alarm_type" label="告警分类" width="150">
                <!--                <template #default="scope">-->
                <!--                  <span>{{alarmTypeListMap['ktaescpce360d81c349bfa49ff4e98219b156ca7495cc64839a4c29ac0cd652ea1e1c1f66a4c983997610e55102dc8519f67a2ba5d3e8dd7']}}</span>-->
                <!--                  <span v-if="scope.row.alarm_type == 1">其他警告</span>-->
                <!--                  <span v-if="scope.row.alarm_type == 2">设备告警</span>-->
                <!--                  <span v-if="scope.row.alarm_type == 3">性能告警</span>-->
                <!--                  <span v-if="scope.row.alarm_type == 4">安全告警</span>-->
                <!--                  <span v-if="scope.row.alarm_type == 5">配置告警</span>-->
                <!--                  <span v-if="scope.row.alarm_type == 6">应用告警</span>-->
                <!--                  <span v-if="scope.row.alarm_type == 9">虚拟化平台</span>-->
                <!--                </template>-->
              </el-table-column>
              <el-table-column
                prop="start_date"
                label="开始时段"
                width="120"
                :formatter="dateFormat"
              >
              </el-table-column>
              <el-table-column
                prop="end_date"
                label="结束时段"
                width="120"
                :formatter="dateFormat"
              >
              </el-table-column>
              <el-table-column prop="inform_type" label="通知类型" width="120">
                <template #default="scope">
                  <span v-if="scope.row.inform_type == '1'">故障通知</span>
                  <span v-if="scope.row.inform_type == '2'">离线通知</span>
                  <span v-if="scope.row.inform_type == '3'">消防通知</span>
                  <span v-if="scope.row.inform_type == '4'">周界通知</span>
                  <span v-if="scope.row.inform_type == '5'">周位通知</span>
                </template>
              </el-table-column>
              <!-- <el-table-column
              prop="inform_template_id"
              label="通知模板ID"
              >
            </el-table-column> -->
              <el-table-column prop="inform_template" label="通知模板"> </el-table-column>
              <el-table-column prop="inform_content" label="通知内容"> </el-table-column>

              <el-table-column fixed="right" label="操作" width="120">
                <template slot-scope="scope">
                  <el-button
                    @click="editClick(scope.row)"
                    type="text"
                    icon="el-icon-edit"
                    style="color: #18bc9c; margin: 3px; padding: 0px"
                    >编辑</el-button
                  >
                  <!-- <el-button @click="delClick(scope.row)" type="text" icon="el-icon-delete"
                    style="color: #FF0000;margin:3px;padding:0px;">删除</el-button> -->
                </template>
              </el-table-column>
            </el-table>

            <div class="pagebox">
              <el-pagination
                @size-change="sizeChange"
                @current-change="currentChange"
                :current-page="param.pageNo"
                :page-sizes="[10, 30, 50, 100, 500]"
                :page-size="param.limit"
                layout="total, sizes, prev, pager, next, jumper"
                :total="dataTotal"
              >
              </el-pagination>
            </div>
          </div>
          <div>
            <el-dialog
              v-if="dialogFormVisible"
              v-dialogDrag
              :title="dialogtitle"
              :visible.sync="dialogFormVisible"
              width="70%"
              top="30px"
              :class="dialogFormVisible == true ? 'action01' : 'action02'"
              :before-close="handleClose"
            >
              <el-form
                :model="formData.datas[0]"
                :rules="rules"
                ref="formdata"
                :inline="true"
              >
                <el-form-item
                  label="告警名称"
                  :label-width="formLabelWidth"
                  prop="event_name"
                >
                  <el-input
                    v-model="formData.datas[0].event_name"
                    placeholder="告警名称"
                    style="width: 215px"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item
                  label="是否转工单"
                  :label-width="formLabelWidth"
                  prop="is_turn_to_order"
                >
                  <el-select
                    v-model="formData.datas[0].is_turn_to_order"
                    style="width: 215px"
                  >
                    <el-option label="是" value="1"></el-option>
                    <el-option label="否" value="0"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="告警分类"
                  :label-width="formLabelWidth"
                  prop="alarm_type"
                >
                  <!-- <el-input v-model="formData.datas[0].alarm_type"  autocomplete="off"></el-input> -->
                  <el-select
                    v-model="formData.datas[0].alarm_type"
                    style="width: 215px"
                    @change="handleOptionChange"
                  >
                    <!-- <el-option label="故障告警" value="1"></el-option>
                    <el-option label="离线告警" value="2"></el-option>
                    <el-option label="消防告警" value="3"></el-option>
                    <el-option label="周界告警" value="4"></el-option>
                    <el-option label="周为告警" value="5"></el-option> -->
                    <el-option
                      v-for="item in AlarmCategoryData"
                      :key="item.category_name"
                      :label="item.category_name"
                      :value="item.category_name"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="告警分类id"
                  :label-width="formLabelWidth"
                  prop="alarm_type_id"
                  style="display: none"
                >
                </el-form-item>
                <el-form-item
                  label="告警等级"
                  :label-width="formLabelWidth"
                  prop="alarm_level"
                >
                  <el-select v-model="formData.datas[0].alarm_level" style="width: 215px">
                    <!-- <el-option label="一般" value="1"></el-option>
                    <el-option label="较严重" value="2"></el-option>
                    <el-option label="严重" value="3"></el-option> -->
                    <el-option
                      v-for="item in AlarmLevelData"
                      :key="item.data_value"
                      :label="item.data_text"
                      :value="item.data_value"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="开始时段"
                  :label-width="formLabelWidth"
                  prop="start_date"
                >
                  <el-time-select
                    placeholder="起始时间"
                    style="width: 215px"
                    @change="startTimeChange"
                    v-model="formData.datas[0].start_date"
                    :picker-options="{
                      start: '00:00',
                      step: '00:15',
                      end: '23:00',
                    }"
                  >
                  </el-time-select>
                </el-form-item>
                <el-form-item
                  label="结束时段"
                  :label-width="formLabelWidth"
                  prop="end_date"
                >
                  <el-time-select
                    placeholder="结束时间"
                    style="width: 215px"
                    @change="endTimeChange"
                    v-model="formData.datas[0].end_date"
                    :picker-options="{
                      start: '00:00',
                      step: '00:15',
                      end: '23:59',
                      minTime: formData.datas[0].start_date,
                    }"
                  >
                  </el-time-select>
                </el-form-item>
                <el-form-item label="通知类型" :label-width="formLabelWidth">
                  <!-- <el-input v-model="formData.datas[0].inform_type"  autocomplete="off"></el-input> -->
                  <!-- <el-select v-model="formData.datas[0].inform_type" placeholder="选择类型" style="width: 215px;">
                    <el-option v-for="(item, i) in selectinform_type" :key="i" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select> -->
                  <el-select
                    v-model="formData.datas[0].inform_type"
                    placeholder="选择类型"
                    style="width: 215px"
                  >
                    <el-option label="故障通知" value="1"></el-option>
                    <el-option label="离线通知" value="2"></el-option>
                    <el-option label="消防通知" value="3"></el-option>
                    <el-option label="周界通知" value="4"></el-option>
                    <el-option label="周位通知" value="5"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="通知模板"
                  :label-width="formLabelWidth"
                  prop="inform_template"
                >
                  <el-input
                    v-model="formData.datas[0].inform_template"
                    placeholder="通知模板"
                    style="width: 215px"
                    autocomplete="off"
                  >
                    <i slot="suffix" class="el-icon-more" @click="loadMap"></i>
                  </el-input>
                </el-form-item>
                <el-form-item
                  label="通知内容"
                  :label-width="formLabelWidth"
                  prop="inform_content"
                >
                  <el-input
                    v-model="formData.datas[0].inform_content"
                    type="textarea"
                    placeholder="通知内容"
                    style="width: 215px"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="handleClose">取 消</el-button>
                <el-button type="primary" @click="save">保存</el-button>
              </div>
            </el-dialog>
          </div>
          <div>
            <el-dialog
              v-if="dialogVisible1"
              v-dialogDrag
              title="选择模板"
              :visible.sync="dialogVisible1"
              width="70%"
              top="30px"
              :class="dialogVisible1 == true ? 'action01' : 'action02'"
            >
              <div>
                <NoticeTemplate @getName="templateName" :key="timer"></NoticeTemplate>
              </div>
              <!-- <span slot="footer" class="dialog-footer">
              <el-button @click="dialogVisible1 = false">取 消</el-button>
              <el-button type="primary" @click="dialogVisible1 = false">确 定</el-button>
            </span> -->
            </el-dialog>
          </div>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import SideHeader from "@/views/inc/SideHeader";
import Navlanmu from "@/views/inc/Navlanmu";
import LeftMenuMessage from "@/views/inc/LeftMenuMessage";
import NoticeTemplate from "@/views/message/components/NoticeTemplate";
import { getDateTimes, numFormat, getDateWeek } from "@/utils/index.js";
import {
  getlist,
  getgridsave,
  getdeletes,
  getAlarmCategory,
  getAlarmLevel,
} from "@/api/message/list";
import moment from "moment";

export default {
  name: "AlarmSetting",
  components: { SideHeader, Navlanmu, LeftMenuMessage, NoticeTemplate },
  data() {
    return {
      selectionChangeData: [],
      loadingdata1: false,
      isloading: false,
      dialogFormVisible: false,
      formLabelWidth: "120px",
      alarmTypeListMap: {
        ktaescpce360d81c349bfa49ff4e98219b156ca7495cc64839a4c29ac0cd652ea1e1c1f66a4c983997610e55102dc8519f67a2ba5d3e8dd7:
          "设备告警",
        ktaescpce360d84436cfad1cff4e98219b156ca7495cc64839a4c29ac0cd652ea1e1c1f66a4c983a264d0a8d73c34eb60c4e4dce2ad046f2:
          "行为告警",
        ktaescpce360d8446393a54eff4e98219b156ca7495cc64839a4c29ac0cd652ea1e1c1f66a4c983b8c06675da3ef529704e68238bbf0e3b8:
          "设备离线告警",
      },
      formData: {
        is_iot: false,
        funId: "msg_alarm_setting",
        datas: [
          {
            event_name: "",
            is_turn_to_order: "",
            alarm_level: "",
            alarm_type: "",
            alarm_type_id: "",
            using_time_range: "",
            inform_type: "",
            inform_template_id: "",
            inform_template: "",
            start_date: "",
            end_date: "",
            inform_content: "",
          },
        ],
      },
      param: {
        funId: "msg_alarm_setting",
        baseSQL: "",
        warnStatus: "",
        name: "",
        offset: 0,
        pageNo: 1,
        limit: 10,
      },
      dataTotal: 0,
      tabledatas: [],
      rules: {
        event_name: [{ required: true, message: "事件名称必填", trigger: "blur" }],
        is_turn_to_order: [
          { required: true, message: "是否转工单必填", trigger: "blur" },
        ],
        alarm_type: [{ required: true, message: "告警分类必填", trigger: "blur" }],
        alarm_level: [{ required: true, message: "告警等级必填", trigger: "blur" }],
        start_date: [{ required: true, message: "开始时段必填", trigger: "blur" }],
        end_date: [{ required: true, message: "结束时段必填", trigger: "blur" }],
        inform_content: [{ required: true, message: "通知内容必填", trigger: "blur" }],
        inform_template: [{ required: true, message: "通知模板必填", trigger: "blur" }],
      },
      dialogtitle: "",
      dialogVisible1: false,
      timer: "",
      selectinform_type: "",
      AlarmCategoryData: [],
      AlarmLevelData: [],
    };
  },
  mounted() {
    //
    this.getDatas();

    this.getTempdata();
  },
  created() {
    this.isloading = false;
  },
  methods: {
    myclick() {
      this.dialogFormVisible = true;
    },
    //判断表单是否变化
    handleClose() {
      // console.log('this.formData.datas[0]',this.formData.datas[0])
      let num = 0;
      for (const key in this.formData.datas[0]) {
        if (this.formData.datas[0][key] == "") {
          // num = num + 0
          num += 0;
        } else if (this.formData.datas[0][key] == null) {
          // num = num + 0
          num += 0;
        } else {
          // num = num + 1
          num += 1;
        }
      }
      if (this.dialogtitle == "新增告警设置") {
        if (num != 0) {
          this.$confirm("表单未保存,是否关闭?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              this.dialogFormVisible = false;
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消关闭",
              });
            });
        } else {
          this.dialogFormVisible = false;
        }
      } else {
        // console.log('222',JSON.stringify(this.formData.datas[0]))
        // console.log('22222',sessionStorage.getItem("initForm"))
        if (
          JSON.stringify(this.formData.datas[0]) == sessionStorage.getItem("initForm")
        ) {
          this.dialogFormVisible = false;
        } else {
          this.$confirm("表单未保存,是否关闭?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              this.dialogFormVisible = false;
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消关闭",
              });
            });
        }
      }
      // console.log('num',num)
    },
    handleOptionChange(val) {
      const filterId = this.AlarmCategoryData.filter((item) => {
        return item.category_name === val;
      });
      this.formData.datas[0].alarm_type_id = filterId[0].category_id;
      // console.log(45555,filterId)
    },
    startTimeChange(e) {
      this.formData.datas[0].start_date = e;
      // console.log('this.formData.datas[0]', this.formData.datas[0])
    },
    endTimeChange(e) {
      this.formData.datas[0].end_date = e;
      // console.log('this.formData.datas[0]', this.formData.datas[0])
    },
    templateName(e) {
      let tempname = e;
      // let type = ''
      // if (tempname[0].inform_type == '1') {
      //   type = '故障通知'
      // } else if (tempname[0].inform_type == '2') {
      //   type = '离线通知'
      // } else if (tempname[0].inform_type == '3') {
      //   type = '消防通知'
      // } else if (tempname[0].inform_type == '4') {
      //   type = '周界通知'
      // } else if (tempname[0].inform_type == '5') {
      //   type = '周位通知'
      // }
      this.formData.datas[0].inform_template = tempname[0].template_name;
      this.formData.datas[0].inform_type = tempname[0].inform_type;
      this.formData.datas[0].inform_template_id = tempname[0].template_id;
      this.formData.datas[0].inform_content = tempname[0].inform_content;
      this.dialogVisible1 = false;
      // console.log('this.formData.datas[0].inform_template',this.formData.datas)
    },
    nodeClick(type, data) {
      this.loadingdata1 = true;
      console.log("nodeClick", type, data);
      this.searchForm = data;
      this.getEnergyQushi();
      this.getEnergyDeptRanking();
      this.getEnergylevelCount();
    },
    //新增按钮
    handleAdd() {
      this.dialogtitle = "新增告警设置";
      if (this.$refs["formdata"]) {
        this.$refs["formdata"].resetFields();
      }
      this.dialogFormVisible = true;
      this.formData.datas[0].alarm_setting_id = "";
      this.formData.datas[0].event_name = "";
      this.formData.datas[0].is_turn_to_order = "";
      this.formData.datas[0].alarm_level = "";
      this.formData.datas[0].alarm_type = "";
      this.formData.datas[0].using_time_range = "";
      this.formData.datas[0].inform_type = "";
      this.formData.datas[0].inform_template = "";
      this.formData.datas[0].start_date = "";
      this.formData.datas[0].end_date = "";
      this.formData.datas[0].inform_content = "";
      this.formData.datas[0].alarm_type_id = "";
      // this.formData.datas[0].startTime = ''
      // this.formData.datas[0].endTime = ''
      this.formData.datas[0].inform_template_id = "";
      this.formData.datas[0].event_id = "";
    },
    // 数据搜索按钮
    onSearch() {
      this.param.pageNo = 1;
      this.getDatas();
    },
    //编辑按钮
    editClick(info) {
      this.getDatas();
      this.dialogtitle = "编辑告警设置";
      this.formData.datas[0] = info;
      this.formData.datas[0].is_turn_to_order = info.is_turn_to_order.toString();
      this.dialogFormVisible = true;
      // const strarr = info.using_time_range.split('-', 2)
      this.formData.datas[0].start_date = this.startdate(info.start_date);
      this.formData.datas[0].end_date = this.enddate(info.end_date);
      if (this.$refs["formdata"]) {
        this.$refs["formdata"].resetFields();
      }
      sessionStorage.setItem("initForm", JSON.stringify(this.formData.datas[0]));
    },
    //双击打开编辑页面
    rowdbclick(row) {
      this.getDatas();
      this.dialogtitle = "编辑告警设置";
      this.formData.datas[0] = row;
      this.formData.datas[0].is_turn_to_order = row.is_turn_to_order.toString();
      this.dialogFormVisible = true;
      this.formData.datas[0].start_date = this.startdate(row.start_date);
      this.formData.datas[0].end_date = this.enddate(row.end_date);
      if (this.$refs["formdata"]) {
        this.$refs["formdata"].resetFields();
      }
      sessionStorage.setItem("initForm", JSON.stringify(this.formData.datas[0]));
    },
    save() {
      this.$refs["formdata"].validate((valid) => {
        if (valid) {
          if (this.formData.datas[0].alarm_setting_id) {
            this.updategetgridsave();
            this.dialogFormVisible = false;
          } else {
            this.addgetgridsave();
            this.dialogFormVisible = false;
          }
        } else {
          return false;
        }
      });
    },
    updategetgridsave() {
      this.formData.datas[0].using_time_range =
        this.formData.datas[0].startTime + "-" + this.formData.datas[0].endTime;
      // console.log('this.formData', this.formData)
      getgridsave(this.formData).then((res) => {
        if (res.data.code == "200") {
          this.$message({
            message: "修改成功",
            type: "success",
          });
          this.getDatas();
        } else {
          this.$message({
            message: "修改失败",
            type: "error",
          });
        }
      });
    },
    addgetgridsave() {
      // console.log('this.formData', this.formData)
      // this.formData.datas[0].using_time_range = this.formData.datas[0].startTime + '-' + this.formData.datas[0].endTime
      console.log("cesThisfORN", this.formData);
      getgridsave(this.formData).then((res) => {
        if (res.data.code == "200") {
          this.$message({
            message: "添加成功",
            type: "success",
          });
          this.getDatas();
        } else {
          this.$message({
            message: "添加失败",
            type: "error",
          });
        }
      });
    },
    delClick() {
      // console.log('info',info)

      var tablefromdata = {
        funId: "msg_alarm_setting",
        ids: "",
      };

      this.selectionChangeData.forEach((item) => {
        tablefromdata.ids += item.alarm_setting_id + ";";
      });

      this.$confirm(`已选择${this.selectionChangeData.length}条数据, 是否删除?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        getdeletes(tablefromdata).then((res) => {
          // if(res.status=='200'){
          if (res.data.code == "200") {
            this.$message({
              message: "删除成功",
              type: "success",
            });
            this.getDatas();
          } else {
            this.$message({
              message: "删除失败",
              type: "error",
            });
          }
          // }
          // else{
          //   this.$message({
          //       message: '删除告警失败',
          //       type: 'error'
          //   });
          //}
        });
      });
    },

    // 复选框按钮
    selectionChange(e) {
      this.selectionChangeData = e;
    },
    handleRowClick(e) {
      this.$refs.talbes.toggleRowSelection(e);
      const _selectData = this.$refs.talbes.selection;
      this.selectionChange(_selectData);
    },
    indexMethod(index) {
      return (this.param.pageNo - 1) * this.param.limit + index + 1;
    },
    sizeChange(val) {
      this.param.limit = val;
      this.getDatas();
    },
    currentChange(val) {
      this.param.pageNo = val;
      this.param.offset = (val - 1) * this.param.limit;
      this.getDatas();
    },
    //获取数据
    getDatas() {
      if (this.param.warnStatus == "" && this.param.name == "") {
        this.param.baseSQL = "";
      } else {
        this.param.baseSQL =
          'alarm_level like "%' +
          this.param.warnStatus +
          '%" and ' +
          'event_name like "%' +
          this.param.name +
          '%"';
      }
      getlist(this.param).then((res) => {
        if (res.status == "200") {
          console.log("查看返回的值", res.data.rows);
          let resdata = res.data;
          this.tabledatas = resdata.rows;
          this.dataTotal = resdata.total;
        }
        this.getAlarmtypelist();
        // this.getAlarmtype()
        this.getAlarmLevel();
      });
    },
    //获取告警分类数据
    getAlarmtypelist() {
      let params = {
        funId: "msg_alarm_category",
        warnStatus: "",
        name: "",
        pageNo: 1,
        pageSize: 10,
        baseSQL: "",
      };
      getlist(params).then((res) => {
        this.AlarmCategoryData = res.data.rows;
        console.log(11113333, res.data.rows);
      });
    },
    // getAlarmtype() {
    //   getAlarmCategory().then(res => {
    //     if (res.status == '200') {
    //       let resdata = res.data
    //       if (resdata.code == '200') {
    //         this.AlarmCategoryData = resdata.data
    //       }
    //     }
    //   })
    // },
    //获取告警等级数据
    getAlarmLevel() {
      getAlarmLevel({ data_text: "消息中心-告警等级" }).then((res) => {
        if (res.status == 200) {
          console.log(1111);
          let resdata = res.data;
          if (resdata.code == 200) {
            this.AlarmLevelData = resdata.data;
            console.log(this.AlarmLevelData);
          }
        }
      });
    },
    loadMap() {
      this.timer = new Date().getTime();
      this.dialogVisible1 = true;
    },
    getTempdata() {
      let fromdata = {};
      fromdata.funId = "msg_inform_template";
      getlist(fromdata).then((res) => {
        if (res.status == "200") {
          let resdata = res.data.rows;
          // console.log('resdata',resdata)
          let inform_type = [];
          resdata.forEach((item) => {
            if (item.auditing == 0) {
              inform_type.push({
                value: item.inform_type,
                label: item.inform_type,
              });
            }
          });
          this.selectinform_type = inform_type;
        }
      });
    },
    startdate(date) {
      return moment(date).format("HH:mm:ss");
    },
    enddate(date) {
      return moment(date).format("HH:mm:ss");
    },
    dateFormat(row, column, cellValue, index) {
      var date = row[column.property];
      if (date == undefined) {
        return "";
      }
      return moment(date).format("HH:mm:ss");
    },
  },
};
</script>
<style>
.kanbao-bigbox .el-loading-spinner .el-loading-text {
  color: #666 !important;
}

.el-select-dropdown {
  min-width: 200px !important;
}
</style>
<style scoped>
.el-main {
  padding: 0px !important;
}

.kanbao-bigbox {
  margin-top: 0px;
}
</style>
<style scoped>
.action01 {
  animation: zoomIn 0.5s;
  animation-iteration-count: 1;
}

.action02 {
  animation: zoomOut 0.5s;
  animation-iteration-count: 1;
}

.righttop-search-box {
  background: #f8f8f8;
  padding: 8px 20px 7px 20px;
  border-bottom: 1px solid #ececec;
  position: fixed;
  top: 0;
  width: calc(100% - 55px);
  z-index: 4;
}

.righttop-search-box .el-form-item {
  margin-bottom: 0px !important;
}

.container-box {
  padding: 10px;
  margin: 50px 0;
}

.pagebox {
  text-align: right;
  padding: 10px;
  position: fixed;
  bottom: 0;
  right: 0;
  width: 100%;
  background-color: #ececec;
  z-index: 4;
}
</style>
